Commit 06adddd4 authored by Kevin Modzelewski's avatar Kevin Modzelewski

thread.allocate_lock

parent 24a56544
...@@ -28,8 +28,8 @@ namespace pyston { ...@@ -28,8 +28,8 @@ namespace pyston {
int AST::next_lineno = 100000; int AST::next_lineno = 100000;
AST::AST(AST_TYPE::AST_TYPE type) : type(type), lineno(++next_lineno) { AST::AST(AST_TYPE::AST_TYPE type) : type(type), lineno(++next_lineno) {
//if (lineno == 100644) // if (lineno == 100644)
//raise(SIGTRAP); // raise(SIGTRAP);
} }
#endif #endif
......
...@@ -45,9 +45,27 @@ Box* startNewThread(Box* target, Box* args) { ...@@ -45,9 +45,27 @@ Box* startNewThread(Box* target, Box* args) {
return boxInt(thread_id ^ 0x12345678901L); return boxInt(thread_id ^ 0x12345678901L);
} }
static BoxedClass* thread_lock_cls;
class BoxedThreadLock : public Box {
public:
BoxedThreadLock() {}
DEFAULT_CLASS(thread_lock_cls);
};
Box* allocateLock() {
return new BoxedThreadLock();
}
void setupThread() { void setupThread() {
thread_module = createModule("thread", "__builtin__"); thread_module = createModule("thread", "__builtin__");
thread_module->giveAttr("start_new_thread", new BoxedFunction(boxRTFunction((void*)startNewThread, BOXED_INT, 2))); thread_module->giveAttr("start_new_thread", new BoxedFunction(boxRTFunction((void*)startNewThread, BOXED_INT, 2)));
thread_module->giveAttr("allocate_lock", new BoxedFunction(boxRTFunction((void*)allocateLock, UNKNOWN, 0)));
thread_lock_cls = new BoxedHeapClass(object_cls, NULL, 0, sizeof(BoxedThreadLock), false);
thread_lock_cls->giveAttr("__name__", boxStrConstant("lock"));
thread_lock_cls->giveAttr("__module__", boxStrConstant("thread"));
thread_lock_cls->freeze();
} }
} }
from thread import start_new_thread from thread import start_new_thread, allocate_lock
import time import time
print type(allocate_lock())
done = 0 done = 0
def run(arg): def run(arg):
global done global done
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment