You should perhaps use a global atomic?